package org.jeecg.modules.supplier.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.CookieUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;

/**
 * @Author twm
 * @Date 2021/6/26 13:41
 * @Param 
 * @return 
 **/
@RestController
public class BaseController {

    @Autowired
    private HttpServletRequest request;
    @Autowired
    private HttpServletResponse response;
    @Autowired
    private RedisUtil redisService;

    /**
     * 获取当前用户
     * @return
     */
        public SysUser getCurrentUser() {
        String loginToken = CookieUtil.readLoginToken(request);
        Object json = redisService.get(loginToken);
        return JSON.parseObject(json.toString(), SysUser.class);
    }

}
